package com.xyht.medicine_management_system.modules.user.controller;


import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.user.entity.req.AuthReq;
import com.xyht.medicine_management_system.modules.user.entity.req.MmsApplicationReq;
import com.xyht.medicine_management_system.modules.user.service.MmsApplicationService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 应用列表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-12-18
 */
@RestController
@RequestMapping("/application")
@SecretBody
public class MmsApplicationController {
    @Resource
    private MmsApplicationService mmsApplicationService;

    @PostMapping("/add")
    @ApiModelProperty(value = "添加应用")
    public ResponseResult addApp(@RequestBody MmsApplicationReq mmsApplicationReq){
        return mmsApplicationService.addApp(mmsApplicationReq);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "删除应用")
    public ResponseResult deleteApp(@RequestBody MmsApplicationReq mmsApplicationReq){
        return mmsApplicationService.deleteApp(mmsApplicationReq);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "修改应用")
    public ResponseResult updateApp(@RequestBody MmsApplicationReq mmsApplicationReq){
        return mmsApplicationService.updateApp(mmsApplicationReq);
    }

    @GetMapping("/list")
    @ApiModelProperty(value = "应用列表")
    public ResponseResult getUserList(@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                      @RequestParam(value = "searchStr",required = false) String searchStr) {
        return mmsApplicationService.getAppList(searchStr, pageNum, pageSize);
    }

    @GetMapping("/detail")
    @ApiModelProperty(value = "应用详情")
    public ResponseResult getAppDetail(@RequestParam(value = "appId") String appId) {
        return mmsApplicationService.getAppDetail(appId);
    }


}

